<!--
 * @Author: [kangjie]
 * @Date: 2022-04-01 14:38:43
 * @LastEditors: [kangjie]
 * @LastEditTime: 2022-04-01 14:51:08
 * @Description: !
-->
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>过滤器</title>
  <script src="https://cdn.bootcdn.net/ajax/libs/vue/2.6.9/vue.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js"></script>
</head>
<body>
  <div id="app">
    {{new Date() | fmtDate}}
    <div :title="new Date() | fmtDate">鼠标悬浮上去展示title</div>
  </div>
  <!-- 过滤器可以使用在两个地方 -->
  <!-- 1.双花括号{{}} -->
  <!-- 2.在v-bind属性中使用 -->
  <script>
    // 全局注册过滤器
    Vue.filter('fmtDate',function(date){
      return moment(date).format('YYYY-MM-DD :HH:mm:ss')
    })
    new Vue({
      el:'#app',
      data:{
        msg:'hello'
      },
      methods:{

      }
    })
  </script>
</body>
</html>